
{if condition="$record"}
<div class="am-form-group am-form-inline">
    <label class="am-u-sm-3 am-form-label">报名人昵称</label>
    <div class="am-u-sm-9">
        <input type="text" name="nickname" value="{$record.nickname}">
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">手机</label>
    <div class="am-u-sm-9">
        <input type="text" name="mobile" class="am-form-field" value="{$record.mobile}">
    </div>
</div>
 <div class="am-form-group">

    <label class="am-u-sm-3 am-form-label">生日</label>
    <div class="am-u-sm-9">
        <input type="date" name="birthday"  value="{$record.birthday}"/>
    </div>
</div> 

<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">性别</label>
    <div class="am-u-sm-9">
        <select name="gender">
            <option value="1" <?php if($record['gender']==1){echo "selected='selected'";} ?>>男</option>
            <option value="2" <?php if($record['gender']==2){echo "selected='selected'";} ?>>女</option>
        </select>
    </div>
</div>

<!-- <div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">身高(单位:cm)</label>
    <div class="am-u-sm-9">
        <input type="text" name="body_height" class="am-form-field" value="{$record.body_height}">
    </div>
</div>
-->

<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">特长</label>
    <div class="am-u-sm-9">
        <input type="text" name="specialty" class="am-form-field" value="{$record.specialty}">
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺名称</label>
    <div class="am-u-sm-9">
        <input type="text" name="shop_name" class="am-form-field" value="{$record.shop_name}">
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺地址</label>
    <div class="am-u-sm-9">
        <input type="text" name="shop_address" class="am-form-field" value="{$record.shop_address}">
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺简介</label>
    <div class="am-u-sm-9">
        <input type="text" name="shop_introduction" class="am-form-field" value="{$record.shop_introduction}">
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">参赛宣言</label>
    <div class="am-u-sm-9">
        <textarea style="height:150px;" name="xuanyan">{$record.xuanyan}</textarea>
    </div>
</div>
{if condition="$record.channel != 0"}
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">来源渠道</label>
    <div class="am-u-sm-9">
        <input type="text" name="channel" class="am-form-field" value="{$channels[$record.channel]}">
    </div>
</div>
{/if}
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">封面</label>
    <div class="am-u-sm-9">
        <span class="text">
            {if condition="$record.cover"}
            <img src="{$record.cover}" width="50px;"/>
            {else/}
            <input type="text" name="cover" class="am-form-field" value="默认第一张" disabled>
            {/if}
        </span>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">上传图片</label>
    <div class="am-u-sm-9">
        <button type="button" class="am-btn am-btn-danger am-btn-sm" id="images">
            <i class="am-icon-cloud-upload"></i> 上传图片</button>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">图片列表</label>
    <div class="am-u-sm-9">
        <div class="am-form-group am-form-file">
            <div id="images-list" class="uploader-list2" style="margin-top: 10px;display: flex;">
                {foreach name="$record.images" id="vo"}
                <div class="item-box" style="min-width: 100px;">
                    <a href="{$vo}" target="_blank" style="margin: 10px 20px;">
                        <img src="{$vo}" style="width:51px;"/>
                        <!--&width=311&height=417-->
                    </a>
                    <input type="hidden" name="images[]" value="{$vo}"/>
                    <div style="cursor: pointer;display:flex;flex-flow: column">
                        <div class="cover-span" data-src="{$vo}">[设为封面]</div>
                        <div class="delete-span">[删除]</div>
                    </div>
                </div>
                {/foreach}
            </div>
        </div>
    </div>
</div>
<!-- <div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">音频文件</label>
    <div class="am-u-sm-9">
        <span class="text">
            {if condition="$record.audio_url"}
            <audio src="{$record.audio_url}" am-u-sm-9="am-u-sm-9">
            您的浏览器不支持audio标签
            </audio>
            {else/}
            无音频
            {/if}
        </span>
    </div>
</div> -->
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">支持数</label>
    <div class="am-u-sm-9">
        <span class="text">
            上班族 : {$record.pass_way_yqsbz} , 微信 : {$record.pass_way_wx} , 总计 : {$record.support}
            {if condition="$is_open"}
            <a href="{:url('total_number',['id'=>$record.id])}" class="btn mini blue total-btn">重新统计</a>
            {/if}
        </span>
    </div>
</div>
{else/}
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">报名人昵称</label>
    <div class="am-u-sm-9">
        <input type="text" name="nickname"/>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">手机</label>
    <div class="am-u-sm-9">
        <input type="text" name="mobile"/>
    </div>
</div>
<!-- <div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">生日</label>
    <div class="am-u-sm-9">
        <input type="date" name="birthday"/>
    </div>
</div> -->
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">性别</label>
    <div class="am-u-sm-9">
        <select name="gender">
            <option value="1">男</option>
            <option value="2">女</option>
        </select>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺名称</label>
    <div class="am-u-sm-9">
        <input type="text" name="shop_name"/>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺地址</label>
    <div class="am-u-sm-9">
        <input type="text" name="shop_address"/>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">店铺简介</label>
    <div class="am-u-sm-9">
        <textarea name="shop_introduction"></textarea>
    </div>
</div>

<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">参赛宣言</label>
    <div class="am-u-sm-9">
        <textarea name="xuanyan"></textarea>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">封面图片地址</label>
    <div class="am-u-sm-9">
        <input type="text" name="cover" class="span6" value=""/>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">上传图片</label>
    <div class="am-u-sm-9">
        <button type="button" class="am-btn am-btn-danger am-btn-sm" id="images">
            <i class="am-icon-cloud-upload"></i> 上传图片</button>
        <div id="images-list" style="margin-top: 10px;display: flex;">
        </div>
    </div>
</div>

<!-- <div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">上传音频</label>
    <div class="am-u-sm-9">
        <button type="button" class="am-btn am-btn-danger am-btn-sm" id="voice">
            <i class="am-icon-cloud-upload"></i> 上传音频</button>
        <div id="voice_box">
        </div>
    </div>
</div> 
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">音频时长</label>
    <div class="am-u-sm-9">
        <input class="form-control uniform_on"  type="text" name="audio_time">
    </div>
</div>
-->
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">添加时间</label>
    <div class="am-u-sm-9">
        <input class="form-control uniform_on"  type="datetime-local" name="create_time">
    </div>
</div>
{/if}
{if condition="$is_open"}
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">审核</label>
    <div class="am-u-sm-9">
        <select name="status">
            <option value="0">--无--</option>
            <option value="1" {eq name="$record.status" value="1"}selected{/eq}>通过</option>
            <option value="2" {eq name="$record.status" value="2"}selected{/eq}>不通过</option>
        </select>
    </div>
</div>
<div class="am-form-group">
    <label class="am-u-sm-3 am-form-label">拒绝理由</label>
    <div class="am-u-sm-9">
        <input type="text" name="no_pass_intro" value="{$record.no_pass_intro}"/>
    </div>
</div>
<div class="am-form-group">
    <div class="am-u-sm-9 am-u-sm-push-3">
        <button type="button" class="am-btn am-btn-primary form-btn">保存修改</button>
        <button type="button" class="am-btn" onclick="history.go(-1);">取消</button>
    </div>
</div>
{/if}

<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">错误信息</div>
        <div class="am-modal-bd error_msg">
            Hello world！
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>

<div class="am-modal am-modal-loading am-modal-no-btn" tabindex="-1" id="my-modal-loading">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">正在载入...</div>
        <div class="am-modal-bd">
            <span class="am-icon-spinner am-icon-spin"></span>
        </div>
    </div>
</div>
<style type="text/css">
    .webuploader-element-invisible {
        position: absolute ;
        clip: rect(1px 1px 1px 1px);
        top: -5px;
        left: -15px;
    }
    .file-item{margin-top: 10px;}
</style>
<script type="text/javascript" src="__PUBLIC__/admin/webuploader/webuploader.html5only.min.js"></script>
<script type="text/javascript">

    $('.form-btn').click(function(){

        var form = $(this).parents('form');
        var url = form.attr('action');
        var formData = form.serializeArray();
        $.ajax({
            url:url,
            type:'post',
            data:formData,
            dataType:'json',
            success:function(result){
                if(result.code == 0){
                    $('.am-modal-hd').text(result.message);
                    $('#my-modal-loading').modal('open');
                    timed();
                }else{
                    $('.error_msg').text(result.message);
                    $('#my-alert').modal('open');
                }
            }
        });
        return false;
    });

    function timed()
    {
        var t=setTimeout("location.href='{:url($code.'/index',['active_id'=>$active_id])}'",1000);
    }

    function timed2()
    {
        var t=setTimeout("location.reload();",1000);
    }

    $('.cover-span').click(function(){
        $.ajax({
            url:'{:url("set_cover",["id"=>$record.id])}',
            type:'post',
            data:{'img':$(this).attr('data-src')},
            dataType:'json',
            success:function(result){
               // $.jGrowl(result.message);
                if(result.code == 0){

                    //alert(result.message);
                    $('.am-modal-hd').text(result.message);
                    $('#my-modal-loading').modal('open');
                    timed2();
                }else{
                    alert(result.message);
                    // $('.error_msg').text(result.message);
                    // $('#my-alert').modal('open');
                }
            }
        });
        return false;
    });

    $('.delete-span').click(function(){
        $(this).parents('.item-box').remove();
    });

    $('.total-btn').click(function(){
        var _this = $(this);
        if(confirm('确定要重新统计票数么？')){
            var url = _this.attr('href');
            $.post(url,function(data){
                if(data.code == 0){
                    $('.am-modal-hd').text(data.message);
                    $('#my-modal-loading').modal('open');
                    timed2();
                }else{
                    $('.error_msg').text(data.message);
                    $('#my-alert').modal('open');
                }
            },'json')
        }
        return false;
    });

    $(document).on('click','.delete_image',function(){
        $(this).parent('.image_item').remove();
    });

    var images = WebUploader.create({

        // 选完文件后，是否自动上传。
        auto: true,

        // 文件接收服务端。
        server: '{:url("files/upload")}',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#images',

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/gif,image/jpeg,image/jpg,image/png,image/svg'
        }
    });

    images.on( 'fileQueued', function( file ) {
        var $li = $(
                '<div id="' + file.id + '" class="file-item thumbnail item-box" style="min-width: 100px;">'+
                '<img src="" style="width:50px;"/>'+
                '<input type="hidden" name="images[]" value=""/>'+
                '<div style="cursor: pointer;display:flex;flex-flow: column">'+
                '<div class="delete-span">[删除]</div>'+
                '</div>'+
                '</div>'
            ),
            $img = $li.find('img');


        // $list为容器jQuery实例
        $('#images-list').append( $li );

        // 创建缩略图
        // 如果为非图片文件，可以不用调用此方法。
        // thumbnailWidth x thumbnailHeight 为 100 x 100
        images.makeThumb( file, function( error, src ) {
            if ( error ) {
                $img.replaceWith('<span>不能预览</span>');
                return;
            }

            $img.attr( 'src', src );
        }, 100, 100 );
    });

    // 文件上传过程中创建进度条实时显示。
    images.on( 'uploadProgress', function( file, percentage ) {
        $.AMUI.progress.start();
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    images.on( 'uploadSuccess', function( file ,data) {
        var e = $( '#'+file.id );
        var input = e.find('input[type=hidden]');
        input.val( '__PUBLIC__'+data.url );
    });

    // 文件上传失败，显示上传出错。
    images.on( 'uploadError', function( file ) {
        var $li = $( '#'+file.id ),$error = $li.find('div.error');
        // 避免重复创建
        if ( !$error.length ) {
            $error = $('<div class="error"></div>').appendTo( $li );
        }
        $error.text('上传失败');
    });

    // 完成上传完了，成功或者失败，先删除进度条。
    images.on( 'uploadComplete', function( file ) {
        $.AMUI.progress.done();
    });
</script>
{if condition="empty($record)"}
<script type="text/javascript">

    var voice = WebUploader.create({

        // 选完文件后，是否自动上传。
        auto: true,

        // 文件接收服务端。
        server: '{:url("files/upload_file")}',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: {id:'#voice',multiple:false},

        accept: {
            title: 'Mp3',
            extensions: 'mp3',
            mimeTypes: 'mp3'
        }

    });

    voice.on( 'fileQueued', function( file ) {

    });

    // 文件上传过程中创建进度条实时显示。
    voice.on( 'uploadProgress', function( file, percentage ) {
        $.AMUI.progress.start();
    });

    // 文件上传成功，给item添加成功class, 用样式标记上传成功。
    voice.on( 'uploadSuccess', function( file ,data) {
        if(data.code == 0){
            var html = '<div class="image_item" style="margin-left: 10px;"><input type="hidden" name="audio_url" value="__PUBLIC__'+data.url+'"/><div><audio src="__PUBLIC__'+data.url+'" controls="controls"></div><a class="delete_image" style="margin-left: 20%;">[ 移除 ]</a></div>';
            $('#voice_box').append(html);
        }else{
            alert(data.error);
        }
    });

    // 文件上传失败，显示上传出错。
    voice.on( 'uploadError', function( file ) {
        var $li = $( '#'+file.id ),$error = $li.find('div.error');
        // 避免重复创建
        if ( !$error.length ) {
            $error = $('<div class="error"></div>').appendTo( $li );
        }
        $error.text('上传失败');
    });

    // 完成上传完了，成功或者失败，先删除进度条。
    voice.on( 'uploadComplete', function( file ) {
        $.AMUI.progress.done();
    });

</script>
{/if}